Repository navigation
Linux copy and paste use the Insert shortcuts - #37
adamshiervani wants to merge 1 commit into
Conversation
A paste did nothing in a Linux terminal, and a copy stopped the program that ran in it. The Mini typed Ctrl+V and Ctrl+C after the OS Services clipboard request, and a terminal takes both as control characters. Paste: a Linux sender that also writes the primary selection says so with bit 2 of the flags in clipboard.capabilities. The Mini then types Shift+Insert: a terminal pastes the primary selection, and other applications paste the clipboard. The Mini sends "clipboard_primary": true in session.config, because a sender sets the bit only for a KVM that accepts it. Without the bit the Mini types Ctrl+V as before. Copy: for a Linux target the Mini types Ctrl+Insert, which copies in a terminal and in other applications. The sender reads the clipboard as before, so this needs no flag. macOS and Windows targets do not change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
@coderabbitai review |
Action performed
|
|
No actionable comments were generated in the recent review. Walkthrough
Change: Bug fix Merge Risk:
|
Problem
With OS Services on a Linux target, a paste from the web UI does nothing in a terminal, and a copy stops the program that runs in the terminal. Both work in other applications, such as GNOME Text Editor.
Cause
For a paste, the sender writes the text to the target's clipboard, and the Mini then types Ctrl+V. For a copy, the Mini types Ctrl+C, and then asks the sender for the clipboard. A Linux terminal takes Ctrl+V and Ctrl+C as control characters: it prints
^Vfor the first and sends an interrupt for the second.Fix
This is the Mini side of jetkvm/kvm#1801 ("fix(os-services): Linux copy and paste use the Insert shortcuts"), with the same behavior.
Paste. Shift+Insert pastes in a terminal and in other applications, but a terminal pastes the primary selection (the text that the user highlighted last), and other applications paste the clipboard. A sender with jetkvm/os-services#5 ("On Linux, a paste also sets the primary selection") writes both, and says so with bit 2 of
flagsinclipboard.capabilities.OSVC_CLIPBOARD_FLAG_PRIMARYinos_services_wire.his the new bit.handle_clipboardinos_services_session.caccepts it, and faults the clipboard service when it comes without the write bit, becauseclipboard.setdoes the write.send_session_configsends"clipboard_primary": true. A sender sets the bit only for a KVM that sends this, because firmware of before rejects unknown bits.jetkvm_os_services.cpasses the bit to the UI asprimaryinguestClipboard, andGuestClipboardStateinstores.tshas the field.pasteShortcutinuseGuestClipboard.tsreturns Shift+Insert whenprimaryis set, Cmd+V for macOS, and Ctrl+V otherwise.With a sender of before the bit is not set, and the Mini types Ctrl+V as before. Shift+Insert without the bit would paste old highlighted text in a terminal.
Copy.
copyShortcutinuseGuestClipboard.tsreturns Ctrl+Insert for a Linux target, which copies in a terminal and in other applications. The sender reads the clipboard as before, so the copy needs no flag.The two UI files have the same change as in jetkvm/kvm#1801. macOS and Windows targets do not change.
Testing
components/jetkvm_os_services/tests/run_host_tests.shpasses. The new testtest_clipboard_primary_flagchecks that read, write and primary together are accepted, that read with primary faults the clipboard service, and that an unknown bit still faults it. The twosession.configtests expectclipboard_primary. The UI lint and the type check pass.Not in this PR
This change is not tested on a Mini. The same behavior is tested on a JetKVM with jetkvm/kvm#1801 and an Intel N100 with Ubuntu 26.04 (GNOME 50 on Wayland): a paste arrives in GNOME Terminal and in Text Editor, and a copy from GNOME Terminal sets the target's clipboard without an interrupt.
Note
Medium Risk
Touches clipboard protocol negotiation and injected keystrokes; backward compatible when senders omit the primary bit, but wrong shortcut choice could paste stale primary selection if mis-negotiated.
Overview
Adds primary-selection support to OS Services clipboard so Linux guest paste/copy works in terminals (Ctrl+V/C are control characters there).
Protocol & firmware: New
OSVC_CLIPBOARD_FLAG_PRIMARY;session.configadvertisesclipboard_primary: true;clipboard.capabilitiesrejects primary without write;guestClipboardJSON includes optionalprimary.UI:
GuestClipboardState.primarydrivespasteShortcut(Shift+Insert when primary is set, else macOS/Windows behavior) and `copyShortcut** (Ctrl+Insert on Linux). Paste/copy macros use these instead of fixed Ctrl+V/C.Tests: Session config and clipboard capability tests updated;
test_clipboard_primary_flagadded.Reviewed by Cursor Bugbot for commit 658f070. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit